<style lang="less">
     @import './index.less';
</style>

<template>
  <div>
    <Button icon="reply" type="text" @click="goForward">上一步</Button>
    <Card dis-hover>
      <Row :gutter="10">
        <i-col span="18">
          <div style="padding:10px">
            <h2>{{companyInfo.customer_name}}
              <!-- <Tag color="blue" type="border" class="margin-left-10 margin-bottom-8">重点客户</Tag> -->
            </h2>
            <Row>
              <i-col span="12">
                <p>纳税人识别号：{{companyInfo.tax_num}}</p>
              </i-col>
              <i-col span="12">
                <p>电话：{{companyInfo.phone_num}}</p>
              </i-col>
            </Row>
            <Row>
              <i-col span="12">
                <p>开户行账号：{{companyInfo.bank_account}}</p>
              </i-col>
              <i-col span="12">
                <p>开户行：{{companyInfo.bank}}</p>
              </i-col>
            </Row>
            <Row>
              <i-col span="12">
                <p>地址：{{companyInfo.address}}</p>
              </i-col>
            </Row>
          </div>
        </i-col>
      </Row>
    </Card>
    <Row :gutter="10" class="margin-top-10">
      <i-col span="17">
        <Card dis-hover>
          <Tabs value="1">
              <TabPane label="相关信息" name="1">
                <Collapse>
                    <Panel name="1">联系人
                      <Table slot="content" :columns="tableData.table1Columns" :data="contacts"></Table>
                    </Panel>
                    <Panel name="2">销售机会
                      <Table slot="content" :columns="tableData.table2Columns" :data="chances"></Table>
                    </Panel>
                    <Panel name="3">合同
                      <Table slot="content" :columns="tableData.table3Columns" :data="business"></Table>     
                    </Panel>
                </Collapse>
              </TabPane>
          </Tabs>
        </Card>
      </i-col>
      <i-col span="7">
        <Card dis-hover>
          <Tabs value="1">
              <TabPane label="动态" name="1">
                <p>动态里的内容</p>
              </TabPane>
              <TabPane label="团队成员" name="2">
                <p>团队成员里的内容</p>
              </TabPane>
          </Tabs>
        </Card>
      </i-col>
    </Row>
  </div>
</template>

<script>
import moment from 'moment';
import tableData from './table_data.js';


export default {
  data() {
    return {
      companyInfo:{},
      customer_id:'',
      contacts:[],
      chances:[],
      business:[],
      tableData:[],
    }
  },
  methods: {
    goForward() {
      this.$router.go(-1)
    },
    getCoustomerInfo(id) {
      this.$http.get('/customer/customers/' + this.customer_id).then((res) => {
        this.companyInfo = res.data.returnValue
      })
    },
    // 联系人
    getContacts() {
      this.$http.get('/customer/customer/' + this.customer_id + '/contacts ').then((res) => {
        this.contacts = res.data.returnValue
      })
    },
    // 机会
    getChances() {
      this.$http.get('/customer/customer/' + this.customer_id + '/chances').then((res) => {
      this.chances = res.data.returnValue
        _.map(this.chances,item => {
          item.predict_sign_date = moment(item.predict_sign_date).format('YYYY-MM-DD')
          return item
        })
      })
    },
    // 合同
    getBusiness() {
      this.$http.get('/fi/contracts?like=&customer_id='+this.customer_id+ '&org_id=&responsible=&status=').then((res) => {
        this.business = res.data.returnValue
      })
    }
  },
  mounted() {
    this.customer_id = this.$route.params.id
    this.getCoustomerInfo()
    this.getContacts()
    this.getChances()
    this.getBusiness()
  },
  created () {
    this.tableData = tableData
  }
}
</script>

